Skip to content

fix: include version in bundled and server package.json files#361

Open
shivammittal274 wants to merge 1 commit intomainfrom
claude/slack-triage-sentry-error-CecuZ
Open

fix: include version in bundled and server package.json files#361
shivammittal274 wants to merge 1 commit intomainfrom
claude/slack-triage-sentry-error-CecuZ

Conversation

@shivammittal274
Copy link
Contributor

Summary

This change ensures that the version field is included in the package.json files generated during the build process, making version information available at runtime for modules that need it.

Key Changes

  • Added version field to the package.json written into the bundle directory in bundleWithPlugins(). This is required by @mariozechner/pi-coding-agent which reads package.json at module load time via getPackageDir() to extract version and config information.
  • Updated the package.json written to dist/server/package.json to also include the version field for consistency.

Implementation Details

  • Both package.json files now include { type: 'module', version } instead of just { type: 'module' }
  • The version variable is already available in the build context and is now being utilized in both locations
  • Added explanatory comment in bundleWithPlugins() documenting why the version is needed for the pi-coding-agent dependency

https://claude.ai/code/session_01RjbFDanzVw73iiFAhh59Kp

…artup

@mariozechner/pi-coding-agent reads package.json at module load time
(config.js:139) via getPackageDir(), which walks up from __dirname looking
for package.json. In production, the bundled index.js runs from a directory
with no package.json, causing a fatal ENOENT that crashes the server.

Write a package.json (with type and version) into the bundle output
directory so it ships alongside the production bundle. Also add version
to the dist/server/package.json for compiled binary deployments.

Slack thread: https://felafax.slack.com/archives/C0AF85H7PK8/p1772028629327479

https://claude.ai/code/session_01RjbFDanzVw73iiFAhh59Kp
@github-actions
Copy link
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement.

To sign the CLA, please add a comment to this PR with the following text:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once. After signing, this check will pass automatically.


Troubleshooting
  • Already signed but still failing? Comment recheck to trigger a re-verification.
  • Signed with a different email? Make sure your commit email matches your GitHub account email, or add your commit email to your GitHub account.
- - - I have read the CLA Document and I hereby sign the CLA - - - You can retrigger this bot by commenting **recheck** in this Pull Request. Posted by the **CLA Assistant Lite bot**.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

This PR fixes an ENOENT crash on startup by ensuring the version field is included in package.json files generated during the server build process. The @mariozechner/pi-coding-agent dependency calls getPackageDir() at module load time to read package.json for version and config information, and the bundle directory previously lacked this file.

  • Added a new writeFileSync call in bundleWithPlugins() to write package.json with { type: 'module', version } into the bundle directory
  • Updated the existing dist/server/package.json write to also include the version field for consistency
  • Both locations correctly reference the version variable already available in their respective scopes

Confidence Score: 5/5

  • This PR is safe to merge — it's a minimal, targeted fix to a build script that adds version info to generated package.json files.
  • The change is small (net +10 lines), limited to a single build script, and uses a variable (version) that is already in scope and well-tested in both locations. No runtime code is modified. The fix addresses a concrete crash (ENOENT) from a known dependency.
  • No files require special attention.

Important Files Changed

Filename Overview
scripts/build/server.ts Adds version field to two package.json files generated during build: one in the bundle directory (new write) and one in the server dist directory (updated existing write). Both correctly use the version variable already available in scope.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[main] --> B[getServerVersion]
    B --> C[build config with version]
    C --> D[build]
    D --> E["write dist/server/package.json\n{ type: 'module', version }"]
    D --> F[bundleWithPlugins envVars, version]
    F --> G["Bun.build() → dist/server/bundle/"]
    G --> H["write dist/server/bundle/package.json\n{ type: 'module', version }"]
    H --> I[compileTarget from bundle]
    I --> J["rmSync bundle dir"]
    E --> K["dist/server/package.json persists\nnext to compiled binary"]
Loading

Last reviewed commit: 1e3e270

@DaniAkash DaniAkash changed the title Include version in bundled and server package.json files fix: include version in bundled and server package.json files Feb 25, 2026
@github-actions github-actions bot added the fix label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants